<div class="layuimini-container layui-anim layui-anim-upbit">
    <div class="layuimini-main">
    
        <table class="layui-hide" id="myTable" lay-filter="currentTableFilter"></table>

        <script type="text/html" id="currentTableBar">
            <a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" lay-event="info">查看详情</a>
        </script>

    </div>
</div>

<script>
	layui.use(['form', 'table','layuimini','element'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table,
            layuimini = layui.layuimini;
            
        table.render({
            elem: '#myTable',
            url: 'getFinishProcessList',
            toolbar: '#toolbarDemo',
            defaultToolbar: ['filter', 'exports', 'print', {
                title: '提示',
                layEvent: 'LAYTABLE_TIPS',
                icon: 'layui-icon-tips'
            }],
            cols: [
		            [
		                {field: 'businessKey', width: 100, title: '业务号'},
		                {field: 'processDefinitionId', width: 120, title: '流程实例ID'},
		                {field: 'leaveapply', width: 100, title: '申请人',templet:function(row){
		                		return row.leaveapply.user_id;
		                	}
		                },
		                {field: 'leaveapply', width: 100, title: '请假类型',templet: function(row){
       						 	return row.leaveapply.leave_type;
      						}
      					},
		                {field: 'leaveapply', width: 250, title: '申请时间',templet: function(row){
       						 	return row.leaveapply.apply_time;
      						}
      					},
		                {title: '操作', minWidth: 80, templet: '#currentTableBar', fixed: "right", align: "center"}
		            ]
            ],
            limits: [10, 15, 20, 25, 50, 100],
            limit: 10,
            page: true
        });
        
        // 监听删除操作
	    table.on('tool(currentTableFilter)', function (obj) {
            var data = obj.data;
            if (obj.event === 'info') {
            	var content = layuimini.getHrefContent('processinfo');
                var openWH = layuimini.getOpenWidthHeight();
                var index = layer.open({
                    title: '流程活动记录',
                    type: 1,
                    shade: 0.2,
                    maxmin:true,
                    shadeClose: true,
                    area: [openWH[0] + 'px', openWH[1] + 'px'],
                    offset: [openWH[2] + 'px', openWH[3] + 'px'],
                    content: content,
                    success:function(){
                    	 $("#process_instance_id").val(data.leaveapply.process_instance_id);
                    	 table.render({
				            elem: '#munu-table',
				            url: 'getProcessInfo?instanceId='+data.leaveapply.process_instance_id,
				            page: false,
				            cols: [
					            [
					                {field: 'activityName', minWidth: 150, title: '活动名称'},
					                {field: 'activityType',width: 150, title: '活动类型'},
					                {field: 'assignee', width: 150,title: '办里人'},
					                {field: 'startTime', width: 200,  title: '活动开始时间'},
					                {field: 'endTime', width: 200,  title: '活动结束时间'}
					            ]
				            ],
				            done: function () {
				                layer.closeAll('loading');
				            }
				        });	
                    	layer.iframeAuto(index);
                    }
                });
                $(window).on("resize", function () {
                    layer.full(index);
                });
                return false;
            }
        });
    });
    
</script>